package com.gitee.free2free.study.elastic.controller;

import com.gitee.free2free.study.elastic.entity.OrderEntity;
import com.gitee.free2free.study.elastic.repository.OrderRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author lfg
 */
@RestController
public class OrderController {
    @Resource
    private OrderRepository orderRepository;

    @GetMapping("findFirstBySpuId")
    public Object findFirstBySpuId(String spuId) {
        return orderRepository.findFirstBySpuId(spuId);
    }


    @PostMapping("save")
    public Object save(@RequestBody OrderEntity orderEntity) {
        return orderRepository.save(orderEntity);
    }


    @GetMapping("findAll")
    public Object findFirstBySpuId() {
        return orderRepository.findAll();
    }

    @GetMapping("findByAdminId")
    public Object findByAdminId(String adminId) {
        return orderRepository.findByAdminId(adminId);
    }
}
